$(function () {
   $('.highlight-btn').click(function (event) {
      var self = $(this) ;
      var tr = self.parent().parent();
      var post_id = tr.attr('data-id');
      var highlight = parseInt(tr.attr('data-highlight'));
       url='';
       if(highlight){
           url='/cms/uhpost/';
       }else {
           url = '/cms/hpost/';
       }
       zlajax.post({
           'url' : url ,
           'data' : {
               'post_id' : post_id
           },
           'success' : function (data) {
               if(data['code']==200){}
               xtalert.alertSuccessToast('操作成功！');
               setTimeout(function () {
                   window.location.reload();
               },500)
           },
           'fail' : function (error) {
               xtalert.alertNetworkError('网络错误！');
           }
       })
   });
});

$(function () {
   $('.banned-btn').click(function () {
      var self = $(this) ;
      var tr = self.parent().parent();
      var post_id = tr.attr('data-id');
      var is_banned = parseInt(tr.attr('data-banned'));
      url = "";
      if(is_banned){
          url = '/cms/banned/';
      }else {
          url = '/cms/unbanned/';
      }
      zlajax.post({
          'url' : url,
          'data' : {
              'post_id' : post_id
          },
          'success' : function (data) {
               if(data['code']==200){}
               xtalert.alertSuccessToast('操作成功！');
               setTimeout(function () {
                   window.location.reload();
               },500)
           },
           'fail' : function (error) {
               xtalert.alertNetworkError('网络错误！');
           }
      })
   }) ;
});